feat!: Add Electrum protocol v1.6 support - #18
Conversation
- Add `ServerVersion` request type (`server.version`) - Add optional `mode` parameter to `EstimateFee` (breaking: new field) - Support both pre-1.6 (concatenated hex) and v1.6 (list of hex strings) response formats for `blockchain.block.headers` - Add `BroadcastPackage` request type (`blockchain.transaction.broadcast_package`) - Add `GetMempoolInfo` request type (`mempool.get_info`) - Add missing `Features` to `gen_pending_request_types!` macro Closes bitcoindevkit#8 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Cover both the pre-1.6 concatenated-hex path and the v1.6 array-of-hex path, asserting they produce equal `Vec<Header>`, plus a sanity check that non-string/non-array inputs are rejected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Capture rejection details when package broadcast fails, and simplify broadcast hex encoding with serialize_hex.
mempool.get_info returns required BTC/kvB floats, so deserialize to FeeRate directly and share conversion with the estimatefee opt helper.
Use blockchain.relayfee in docs and switch the README sample to GetMempoolInfo for v1.6.
caarloshenriq
left a comment
There was a problem hiding this comment.
I noticed ServerVersionResp.protocol_version is returned from server.version but never stored anywhere in AsyncClient. So if a caller wants to honor the responsibility this issue assigns them, checking the negotiated version before using mode, they have to track that state entirely on their own, with no help from the library.
Confirmed live against Fulcrum 1.12.0 (negotiates 1.5.3): sending mode there returns a generic JSON-RPC error, not something that signals "your protocol version is too low."
|
We intentionally leave that up to the user for now for simplicity. We can think about changing this in the future. |
There was a problem hiding this comment.
ACK c1619bc
Thanks for the doc corrections. Custom serde logic is clean. Request/Response types are correct.
| /// | ||
| /// See: <https://electrum-protocol.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-broadcast-package> | ||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct BroadcastPackage(pub Vec<bitcoin::Transaction>); |
There was a problem hiding this comment.
We can add the BroadcastPackageVerbose request type as a follow-up.
Summary
Add support for Electrum protocol v1.6 methods and response format changes.
ServerVersionrequest type forserver.version(version negotiation)EstimateFeegains an optionalmodeparameter (EstimateFeeMode::{Economical, Conservative})blockchain.block.headersresponses support both pre-1.6 (concatenated hex"hex") and v1.6 (list of hex strings"headers") formatsBroadcastPackagerequest type forblockchain.transaction.broadcast_package(package relay)GetMempoolInforequest type formempool.get_info(replacesblockchain.relayfee)RelayFeeretained for pre-1.6 serversFeaturestogen_pending_request_types!macroGetMempoolInfoCloses #8
Supersedes #11
Notes to the reviewers